package org.example;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;
import java.util.zip.CheckedInputStream;

public class webApplication extends Application {
    @Override
    public void start(Stage stage) throws IOException {

        VBox vBox = new VBox();
        VBox.setVgrow(vBox, Priority.ALWAYS);
        URL resource = getClass().getResource("icon.png");

        if (resource != null) {
            stage.getIcons().add(new Image(resource.openStream()));
        }

        WebView webView = new WebView();
        VBox.setVgrow(webView, Priority.ALWAYS);
        HBox.setHgrow(webView, Priority.ALWAYS);
        // 加载一个本地的 HTML 文件
        URL cssUrl = getClass().getResource("minesweeper.html");

        if (cssUrl != null) {
            String Path = cssUrl.getPath();
            System.out.println(Path);

            webView.getEngine().load("file://" + Path);
        }else {
            System.out.println("没有找到index.html");
        }
        vBox.getChildren().add(webView);


        Scene scene = new Scene(vBox, 1250, 900);

        stage.setTitle("天面Ai");
        stage.setScene(scene);
        stage.setMinWidth(1250);
        stage.setMinHeight(920);
        stage.show();

    }
}
